package org.fuxia.im.common;

import java.util.ArrayList;
import java.util.List;

import javax.swing.AbstractListModel;

import org.fuxia.im.common.MyListCellModel.ShowUser;

public class MyListCellModel extends AbstractListModel<ShowUser> {

	private static final long serialVersionUID = 1L;
	
	List<ShowUser> data = new ArrayList<ShowUser>() ;
	
	public int getSize() {
		return data.size();
	}

	public ShowUser getElementAt(int index) {
		return data.get(index);
	}
	
	public void addUser(ShowUser user) {
		this.data.add(user);
	}
	
	public void addObject(Object[] user) {
		if(user.length!=2) {
			throw new RuntimeException("数据长度不正确");
		}
		addUser(new ShowUser(user[0].toString(),user[1].toString()));
	}
	
	public void addData(Object[][] datas) {
		for(Object[] obj:datas){
			addObject(obj) ;
		}
	}
	
	public static class ShowUser {
		private String userCode ;
		private String nickName ;
		private boolean isSelected ;
		
		public ShowUser(){
		}
		public ShowUser(String userCode, String nickName) {
			this.userCode = userCode;
			this.nickName = nickName;
			this.isSelected = false ;
		}

		public String getUserCode() {
			return userCode;
		}
		public void setUserCode(String userCode) {
			this.userCode = userCode;
		}
		public String getNickName() {
			return nickName;
		}
		public void setNickName(String nickName) {
			this.nickName = nickName;
		}
		
		public boolean isSelected() {
			return isSelected;
		}
		public void setSelected(boolean isSelected) {
			this.isSelected = isSelected;
		}
		
		
	}
	


}
